﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="bas_user.aspx.cs" Inherits="bas_user" %>
<%@ Register Src="~/UserControls/ucFavorite.ascx" TagName="ucFavorite" TagPrefix="Kerry" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="Server">
  <%--<style type="text/css">
  input[type="text"] {
    width: 80%; }
  </style>--%>
  <table class="ConditionTable">
    <tr>
      <th colspan="2"><Kerry:ucFavorite ID="ucFavorite" runat="server" />使用者維護
      </th>
    </tr>
    <tr>
      <td>使用者代號 :
                <asp:TextBox ID="txtUSER_ID" runat="server" MaxLength="17"></asp:TextBox>
      </td>
      <td>使用者姓名：<asp:TextBox ID="txtUSER_NAME" runat="server" MaxLength="30"></asp:TextBox>
      </td>
    </tr>
    <tr>
      <td>部門代號 :
                <asp:DropDownList ID="ddlDEPT_ID" DataValueField="DEPT_ID" AppendDataBoundItems="true" DataTextField="DEPT_NAME" runat="server">
                  <asp:ListItem Text="" Value=""></asp:ListItem>
                </asp:DropDownList>
      </td>
      <td>群組 :
                <asp:DropDownList ID="ddlROLE_ID" DataValueField="ROLE_ID" AppendDataBoundItems="true" DataTextField="ROLE_NAME" runat="server">
                  <asp:ListItem Text="" Value=""></asp:ListItem>
                </asp:DropDownList>
      </td>
    </tr>
    <tr>
      <td colspan="2">

        <asp:Button ID="btn_search" runat="server" Text="搜尋" OnClick="btnQuery_Click" />
        <asp:Button ID="btn_exist" runat="server" Text="離開" OnClick="btn_exist_Click" />
      </td>
    </tr>
  </table>
  <br />
  <asp:Label ID="lbl_Message" runat="server" Text="" ForeColor="Red"></asp:Label><asp:HiddenField ID="hid_Message" Value="資料確定要刪除？" runat="server" />

  <asp:ListView ID="DV1" runat="server" DataKeyNames="USER_ID" InsertItemPosition="LastItem" OnItemCanceling="DV1_ItemCanceling" OnItemEditing="DV1_ItemEditing" OnItemDeleting="DV1_ItemDeleting" OnItemInserting="DV1_ItemInserting" OnItemUpdating="DV1_ItemUpdating" OnPagePropertiesChanging="DV1_PagePropertiesChanging" OnPagePropertiesChanged="DV1_PagePropertiesChanged" OnItemCreated="DV1_ItemCreated" OnItemDataBound="DV1_ItemDataBound">

    <EditItemTemplate>
      <tr>
        <td rowspan="2">
          <asp:Button ID="btn_save" runat="server" CommandName="Update" Text="存檔" ValidationGroup="EDIT" />
          <asp:Button ID="btn_cancel" runat="server" CommandName="Cancel" Text="取消" />
        </td>
        <td>
          <asp:Label ID="lblUSER_ID" runat="server" Width="95%" Text='<%# Eval("USER_ID") %>' />
          <asp:TextBox ID="txtUSER_ID_1" runat="server" Text='<%# Bind("USER_ID") %>' Visible="false" />
        </td>
        <td>
          <asp:TextBox ID="txtUSER_NAME_1" runat="server" MaxLength="30" Width="95%" Text='<%# Bind("USER_NAME") %>' />
          <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ValidationGroup="EDIT" ControlToValidate="txtUSER_NAME_1" runat="server" SetFocusOnError="true" ErrorMessage="不可空白" ForeColor="Red"></asp:RequiredFieldValidator>
        </td>
        <td>
          <asp:TextBox ID="txtUSER_PASSWORD" runat="server" MaxLength="30" Width="95%" Text='<%# Bind("USER_PASSWORD") %>' />
          <asp:RequiredFieldValidator ID="RequiredFieldValidator3" ValidationGroup="INSERT" ControlToValidate="txtUSER_PASSWORD" runat="server" SetFocusOnError="true" ForeColor="Red" ErrorMessage="不可空白"></asp:RequiredFieldValidator>
        </td>
        <td>
          <asp:TextBox ID="txtDEPT_ID_1" runat="server" Visible="false" Text='<%# Bind("DEPT_ID") %>' />
          <asp:DropDownList ID="ddlDEPT_ID_1" Width="90%" DataValueField="DEPT_ID" AppendDataBoundItems="true" DataTextField="DEPT_NAME" runat="server">
          </asp:DropDownList>
          <asp:RequiredFieldValidator ID="RequiredFieldValidator4" ValidationGroup="INSERT" ControlToValidate="ddlDEPT_ID_1" runat="server" SetFocusOnError="true" ForeColor="Red" ErrorMessage="不可空白"></asp:RequiredFieldValidator>
        </td>
        <td>
          <asp:TextBox ID="txtROLE_ID_1" runat="server" Visible="false" Text='<%# Bind("ROLE_ID") %>' />
            <asp:DropDownList ID="ddlROLE_ID_1" Width="100%" DataValueField="ROLE_ID" AppendDataBoundItems="true" DataTextField="ROLE_NAME" runat="server">
            <asp:ListItem Text="" Value=""></asp:ListItem>
          </asp:DropDownList>
          <%--<asp:RequiredFieldValidator ID="RequiredFieldValidator7" ValidationGroup="INSERT" ControlToValidate="ddlROLE_ID" runat="server" SetFocusOnError="true" ForeColor="Red" ErrorMessage="不可空白" ></asp:RequiredFieldValidator>--%>
            <asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="ddlROLE_ID_1" ErrorMessage="CustomValidator"></asp:CustomValidator>
        </td>
        <td>
          <asp:TextBox ID="txtPARENT_USER_ID" runat="server" MaxLength="17" Width="95%" Text='<%# Bind("PARENT_USER_ID") %>' />
          <asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="不可與公司代號相同" ControlToValidate="txtPARENT_USER_ID" ControlToCompare="txtUSER_ID_1" ValidationGroup="EDIT" Operator="NotEqual" ForeColor="Red" SetFocusOnError="true"></asp:CompareValidator>
        </td>

      </tr>
      <tr>
        <td colspan="3">
          <asp:TextBox ID="txtE_MAIL1" runat="server" TextMode="Email" MaxLength="30" Width="95%" Text='<%# Bind("E_MAIL1") %>' />
          <br />
          <asp:RequiredFieldValidator ID="RequiredFieldValidator5" ValidationGroup="INSERT" ControlToValidate="txtE_MAIL1" runat="server" SetFocusOnError="true" ForeColor="Red" ErrorMessage="不可空白"></asp:RequiredFieldValidator>
          <asp:RegularExpressionValidator ID="RegularExpressionValidator1" ValidationGroup="INSERT" ForeColor="Red" runat="server" ControlToValidate="txtE_MAIL1" SetFocusOnError="true" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ErrorMessage="Invalid Email" BorderStyle="None"></asp:RegularExpressionValidator>
        </td>
        <td colspan="3">
          <asp:TextBox ID="txtE_MAIL2" runat="server" TextMode="Email" MaxLength="30" Width="95%" Text='<%# Bind("E_MAIL2") %>' />
          <br />
          <asp:RegularExpressionValidator ID="RegularExpressionValidator2" ValidationGroup="INSERT" ForeColor="Red" runat="server" ControlToValidate="txtE_MAIL2" SetFocusOnError="true" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ErrorMessage="Invalid Email"></asp:RegularExpressionValidator>
        </td>
      </tr>
    </EditItemTemplate>
    <EmptyDataTemplate>
      <table id="Table1" runat="server" style="background-color: #FFFFFF; border-collapse: collapse; border-color: #999999; border-style: none; border-width: 1px;">
        <tr>
          <td>未傳回資料。</td>
        </tr>
      </table>
    </EmptyDataTemplate>
    <InsertItemTemplate>
      <tr style="">
        <td rowspan="2">
          <asp:Button ID="btn_save" runat="server" CommandName="Insert" Text="新增" ValidationGroup="INSERT" />
          <asp:Button ID="btn_cancel" runat="server" CommandName="Cancel" Text="清除" />
        </td>
        <td>
          <asp:TextBox ID="txtUSER_ID_1" runat="server" MaxLength="17" Width="95%" Text='<%# Bind("USER_ID") %>' ViewStateMode="Enabled" />
          <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ValidationGroup="INSERT" ControlToValidate="txtUSER_ID_1" runat="server" SetFocusOnError="true" ForeColor="Red" ErrorMessage="不可空白"></asp:RequiredFieldValidator>
        </td>
        <td>
          <asp:TextBox ID="txtUSER_NAME_1" runat="server" MaxLength="30" Width="95%" Text='<%# Bind("USER_NAME") %>' />
          <asp:RequiredFieldValidator ID="RequiredFieldValidator2" ValidationGroup="INSERT" ControlToValidate="txtUSER_NAME_1" runat="server" SetFocusOnError="true" ForeColor="Red" ErrorMessage="不可空白"></asp:RequiredFieldValidator>
        </td>
        <td>
          <asp:TextBox ID="txtUSER_PASSWORD" runat="server" MaxLength="30" Width="95%" Text='<%# Bind("USER_PASSWORD") %>' />

          <asp:RequiredFieldValidator ID="RequiredFieldValidator3" ValidationGroup="INSERT" ControlToValidate="txtUSER_PASSWORD" runat="server" SetFocusOnError="true" ForeColor="Red" ErrorMessage="不可空白"></asp:RequiredFieldValidator>
        </td>
        <td>
          <asp:DropDownList ID="ddlDEPT_ID_1" Width="90%" DataValueField="DEPT_ID" AppendDataBoundItems="true" DataTextField="DEPT_NAME" runat="server">
            <asp:ListItem Text="" Value=""></asp:ListItem>
          </asp:DropDownList>

          <asp:RequiredFieldValidator ID="RequiredFieldValidator4" ValidationGroup="INSERT" ControlToValidate="ddlDEPT_ID_1" runat="server" SetFocusOnError="true" ForeColor="Red" ErrorMessage="不可空白"></asp:RequiredFieldValidator>
        </td>
        <td>
          <asp:DropDownList ID="ddlROLE_ID_1" Width="98%" DataValueField="ROLE_ID" AppendDataBoundItems="true" DataTextField="ROLE_NAME" runat="server">
            <asp:ListItem Text="" Value=""></asp:ListItem>
          </asp:DropDownList>
            <asp:CustomValidator ID="CustomValidator2" ControlToValidate="ddlROLE_ID_1" runat="server" ErrorMessage="CustomValidator"></asp:CustomValidator>
          <%--<asp:RequiredFieldValidator ID="RequiredFieldValidator6" ValidationGroup="INSERT" ControlToValidate="ddlROLE_ID" runat="server" SetFocusOnError="true" ForeColor="Red" ErrorMessage="不可空白" ></asp:RequiredFieldValidator>--%>
        </td>
        <td>
          <asp:TextBox ID="txtPARENT_USER_ID" runat="server" MaxLength="17" Width="98%" Text='<%# Bind("PARENT_USER_ID") %>' />
          <asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="不可與使用者代號相同" ControlToValidate="txtPARENT_USER_ID" ControlToCompare="txtUSER_ID_1" ValidationGroup="INSERT" Operator="NotEqual" ForeColor="Red" SetFocusOnError="true" Display="Dynamic"></asp:CompareValidator>
            <asp:CustomValidator ID="CustomValidator3" ControlToValidate="txtPARENT_USER_ID" runat="server" ErrorMessage="CustomValidator"></asp:CustomValidator>
        </td>

      </tr>
      <tr>
        <td colspan="3">
          <asp:TextBox ID="txtE_MAIL1" runat="server" MaxLength="30" TextMode="Email" Text='<%# Bind("E_MAIL1") %>' Width="95%" />
          <asp:RequiredFieldValidator ID="RequiredFieldValidator5" ValidationGroup="INSERT" ControlToValidate="txtE_MAIL1" runat="server" SetFocusOnError="true" ForeColor="Red" ErrorMessage="不可空白" Display="Dynamic"></asp:RequiredFieldValidator>
          <asp:RegularExpressionValidator ID="RegularExpressionValidator1" ValidationGroup="INSERT" runat="server" ControlToValidate="txtE_MAIL1" SetFocusOnError="true" ForeColor="Red" ErrorMessage="Invalid Email" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" BorderStyle="None"></asp:RegularExpressionValidator>
        </td>
        <td colspan="3">
          <asp:TextBox ID="txtE_MAIL2" runat="server" MaxLength="30" TextMode="Email" Text='<%# Bind("E_MAIL2") %>' Width="95%" />
          <asp:RegularExpressionValidator ID="RegularExpressionValidator2" ValidationGroup="INSERT" runat="server" ControlToValidate="txtE_MAIL2" SetFocusOnError="true" ForeColor="Red" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ErrorMessage="Invalid Email" Display="Dynamic"></asp:RegularExpressionValidator>
          <asp:CustomValidator ID="CustomValidator4" ControlToValidate="txtE_MAIL2" runat="server" ErrorMessage="CustomValidator"></asp:CustomValidator>
        </td>
      </tr>
    </InsertItemTemplate>
    <ItemTemplate>
      <tr style="background-color: #FFFBD6; color: #333333;">
        <td rowspan="2">
          <asp:Button ID="btn_delete" runat="server" CommandName="Delete" Text="刪除" OnClientClick="if (!confirm('資料確定刪除？')){return false;}" />
          <asp:Button ID="btn_edit" runat="server" CommandName="Edit" Text="修改" />
        </td>
        <td>
          <asp:Label ID="lblUSER_ID" runat="server" Text='<%# Eval("USER_ID") %>' />
        </td>
        <td>
          <asp:Label ID="lblUSER_NAME" runat="server" Text='<%# Eval("USER_NAME") %>' />
        </td>
        <td>
          <asp:Label ID="lblUSER_PASSWORD" runat="server" Text="********" />
        </td>

        <td>
          <asp:Label ID="lblDEPT_ID" runat="server" Text='<%# Eval("DEPT_NAME") %>' />
        </td>
        <td>
          <asp:Label ID="lblROLE_ID" runat="server" Text='<%# Eval("ROLE_NAME") %>' />
        </td>
        <td>
          <asp:Label ID="lblPARENT_USER_ID" runat="server" Text='<%# Eval("PARENT_USER_ID") %>' />
        </td>

      </tr>
      <tr style="background-color: #FAFAD2; color: #284775;">
        <td colspan="3">
          <asp:Label ID="lblEMAIL_1" runat="server" Text='<%# Eval("E_MAIL1") %>' />

        </td>
        <td colspan="3">
          <asp:Label ID="lblEMAIL_2" runat="server" Text='<%# Eval("E_MAIL2") %>' />
        </td>

      </tr>
    </ItemTemplate>
    <LayoutTemplate>
      <table id="Table2" runat="server">
        <tr id="Tr1" runat="server">
          <td id="Td1" runat="server">
            <table id="itemPlaceholderContainer" runat="server" border="1" style="background-color: #FFFFFF; border-collapse: collapse; border-color: #999999; border-style: none; border-width: 1px; font-family: Verdana, Arial, Helvetica, sans-serif;">
              <tr id="Tr2" runat="server" style="background-color: #FFFBD6; color: #333333;">
                <th id="Th1" style="width: 15%" rowspan="2" runat="server"></th>
                <th id="Th2" style="width: 15%" runat="server">使用者代號</th>
                <th id="Th3" style="width: 15%" runat="server">使用者姓名</th>
                <th id="Th4" style="width: 10%" runat="server">使用者密碼</th>
                <th id="Th5" style="width: 15%" runat="server">部門代號</th>
                <th id="Th9" style="width: 15%" runat="server">群組代號</th>
                <th id="Th6" style="width: 15%" runat="server">主管</th>
              </tr>
              <tr id="Tr4" runat="server" style="background-color: #FFFBD6; color: #333333;">
                <th id="Th7" colspan="3" runat="server">E-Mail1</th>
                <th id="Th8" colspan="3" runat="server">E-Mail2</th>

              </tr>
              <tr id="itemPlaceholder" runat="server">
              </tr>
            </table>
          </td>
        </tr>
        <tr id="Tr3" runat="server">
          <td id="Td2" runat="server" style="text-align: left; background-color: #FFCC66; font-family: Verdana, Arial, Helvetica, sans-serif; color: #333333;">
            <asp:DataPager ID="DataPager1" runat="server" PagedControlID="DV1" PageSize="10">
              <Fields>
                <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowLastPageButton="True" FirstPageText="第一頁" LastPageText="最後一頁" NextPageText="下一頁" PreviousPageText="上一頁" />
              </Fields>
            </asp:DataPager>
            <asp:Label ID="lbl_seq" runat="server" Text="第" />
            <asp:DropDownList ID="uxGoToPageDropDownList" runat="server" AutoPostBack="True"
              OnSelectedIndexChanged="uxGoToPageDropDownList_SelectedIndexChanged" />
            /
            <asp:Label ID="lbl_total_page_count" runat="server" /><asp:Label ID="lbl_page" runat="server" Text="頁" />
            每頁
            <asp:DropDownList ID="uxOnePageCountDropDownList" runat="server"
              AutoPostBack="True"
              OnSelectedIndexChanged="uxOnePageCountDropDownList_SelectedIndexChanged">
              <asp:ListItem>10</asp:ListItem>
              <asp:ListItem>20</asp:ListItem>
              <asp:ListItem>30</asp:ListItem>
            </asp:DropDownList>筆
             <asp:Label ID="lbl_total" runat="server" Text="總筆數 : " />
            <asp:Label ID="lbl_total_counter" runat="server" />
          </td>
        </tr>
      </table>
    </LayoutTemplate>

  </asp:ListView>
  <br />
</asp:Content>

